package com.m3958.firstgwt.client.datasource;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.m3958.firstgwt.client.constants.AssetFolderFieldConstants;
import com.m3958.firstgwt.shared.type.CommonField;
import com.m3958.firstgwt.shared.type.SmartConstants;
import com.m3958.firstgwt.shared.type.SmartParameterName;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;


@Singleton
public class AssetFolderDataSource extends BaseDataSource{

  
    public static String className = "com.m3958.firstgwt.server.model.AssetFolder";

    @Inject
    public AssetFolderDataSource(DsErrorHandler deh,AssetFolderFieldConstants constants) {
    	setID("assetFolderDs");
    	setTitleField("name");
        DataSourceIntegerField parentField = new DataSourceIntegerField(SmartParameterName.PARENTID,SmartParameterName.PARENTID);

        parentField.setForeignKey(id + "." + CommonField.ID.getValue());
        parentField.setRequired(true);
        parentField.setRootValue(SmartConstants.NONE_EXIST_MODEL_ID);
        
        
        DataSourceTextField nameField = new DataSourceTextField(CommonField.NAME.getValue(),constants.name());
        DataSourceTextField descriptionField = new DataSourceTextField(CommonField.DESCRIPTION.getValue(),constants.description());
        DataSourceTextField protectLevelField = new DataSourceTextField(CommonField.PROTECT_LEVEL.getValue(),constants.protectLevel());
        
        addHandleErrorHandler(deh);
        setFields(nameField,getIdField(),getCreatedAtField(false,constants),parentField,getVersionField(),getPositionField(constants),getPerpageField(constants),protectLevelField,descriptionField);
        setClientOnly(false);
    }

	@Override
	protected String getModelClassName() {
		return className;
	}
}
